using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MessageSystem.Managed;
using MessageSystem.Managed.Rpc;
using MessageSystem.Managed.Infrastructure;
using MessageSystem.Managed.Interface;
using Test.Protocol;

namespace TestServer
{
	class TestServer : IPing, IPingAsyn
	{
		public int Ping(string content)
		{
			throw new NotImplementedException();
		}

		public void Ping(string content, Action<int> callback)
		{
			callback(110);
		}
	}

	//class Test
	//{
	//    public static void DoIt(string s)
	//    {
	//        Console.WriteLine(s);
	//    }
	//}

	class Program
	{
		static RpcCenter rpc;
		static RpcAddress address;
		static void Main(string[] args)
		{
			rpc = new RpcCenter(Options.Default,MessageSystemType.Default);
			address = new RpcAddress { Ip = "127.0.0.1", Port = 8001, Name = "测试域" };
			rpc.CreateDomain(address, domain =>
				{
					Console.WriteLine("GetDomain");
					TestServer test = new TestServer();
					domain.BindService<PingProxy,IPing>(0,test,() => { Console.WriteLine("IPing服务丢失"); });
				});
			while (true)
			{
				rpc.Poll(10);
			}
		}
	}
}
